﻿@model SimpComm.PagedModel
@{
    //文本编写器
    var razorWriter = ViewContext.Writer;

    //路由参数
    var routeData = new RouteValueDictionary { { "page", ViewData["PageIndex"].ToString() }, { "pageSize", Model.PageSize } };
    if (ViewData["MyRoutes"] != null)
    {
        var MyRoutes = (Dictionary<string, object>)ViewData["MyRoutes"];
        foreach (var o in MyRoutes)
        {
            routeData.Add(o.Key, o.Value);
        }
    }
    var htmlAttributes = new Dictionary<string, object>() { };
    htmlAttributes.Add("data-trigger", "ajax");
    htmlAttributes.Add("data-target", "#ajax_target");

    var linkMarkup = Html.ActionLink(
            ViewData["Text"].ToString(),                                    // 超链接文本
            Html.ViewContext.RouteData.Values["action"].ToString(),         // Action
            Html.ViewContext.RouteData.Values["controller"].ToString(),     // Controller
            routeData,                                                      // 路由参数
            htmlAttributes                                                  // HTML属性适用于超链接
        ).ToHtmlString();

    //判断是否为选中状态 添加CSS样式
    if ((bool)ViewData["Selected"])
    {
        razorWriter.Write("<li class=\"active\">" + linkMarkup + "</li>");
    }
    else
    {
        razorWriter.Write("<li>" + linkMarkup + "</li>");
    }
        
}
